<%--
  Created by IntelliJ IDEA.
  User: User
  Date: 2020/6/1
  Time: 21:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>购买结果</title>
</head>
<jsp:useBean id="db" class='hello.DB'></jsp:useBean>
<body style="background:url(page/interface.jpg)">
hello：<%out.print(session.getAttribute("user"));%><br><br>

<%@ page import="java.sql.*" %>

<%
    db.init();
    String price;
    String time=(String)session.getAttribute("day");
    if(request.getParameter("seattype").equals("一等座"))
        price=(String)session.getAttribute("price2");
    else price=(String)session.getAttribute("price");

    String s="exec order_exist '"+session.getAttribute("user")+"','"
            +session.getAttribute("trainnum")
            +"','"+request.getParameter("passenger")+"','"+time+"'";
    ResultSet rs=db.executeQuery(s);
    if(rs.next()){
%>
<h1 align="center">请勿重复提交！</h1><br>
<%
}
else{
%>
<h1 align="center">支付成功！请返回</h1><br>
<%
        String sql="exec order_insert '"+session.getAttribute("user")
                +"','"+request.getParameter("seattype")
                +"','"+session.getAttribute("trainnum")
                +"','"+session.getAttribute("begin")
                +"','"+session.getAttribute("end")+"','购票','成功' ,'"
                +request.getParameter("passenger")+"','"
                +request.getParameter("idnum")+"','"
                +request.getParameter("xt")+"','"+time+"'";
        db.executeQuery(sql);

        //座位减少//乘客++
        sql="exec seat_opearing '"+session.getAttribute("trainnum")
                +"','"+session.getAttribute("begin")
                +"','"+session.getAttribute("end")+"','"+request.getParameter("seattype")
                +"','"+time+"','+'";
        db.executeQuery(sql);
    }

    db.close();

%>
</body>
</html>
